﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;

namespace iVision
{
    public class IDValidationRule : ValidationRule
    {
        private int maxIDLength;
        readonly String markupUID = "IDValidationErrorMessage";
        readonly String markupProperty = "Text";
        public int MaxIDLength
        {
            get { return maxIDLength; }
            set { maxIDLength = value; }
        }
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            String InputID = (String)value;
            
            if (InputID.Length > maxIDLength) return new ValidationResult(false,App.currentDictionary.Translate(markupUID,markupProperty,"ID Cannot Be Longer Than " + maxIDLength.ToString() + " Characters.",typeof(object)));
            //if (InputID.) return new ValidationResult(false, App.currentDictionary.Translate(markupUID, markupProperty, "ID Cannot Be Longer Than " + maxIDLength.ToString() + " Characters.", typeof(object)));
            return new ValidationResult(true, null);
        }
    }
}
